<%--
  Created by IntelliJ IDEA.
  User: wyp
  Date: 2020/5/27
  Time: 18:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <link rel="stylesheet" type="text/css" href="./resources/lib/layui/css/main.css">
    <link rel="stylesheet" type="text/css" href="./resources/lib/layui/css/layui.css">
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="./resources/css/bootstrap.css" />
    <link rel="stylesheet" href="./resources/css/style.css" type="text/css" media="all"/>
    <!--引入JQuery，必须要在bootstrap.js之前引入-->
    <script type="text/javascript" src="./resources/js/jquery-3.4.1.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script type="text/javascript" src="./resources/js/bootstrap.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="./resources/js/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="./resources/css/font.css">
    <link rel="stylesheet" href="./resources/css/xadmin.css">
    <script src="./resources/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./resources/js/xadmin.js"></script>
    <title>我的订单</title>
</head>
<body>

<!--头部文件-->
<%@include file="./index/top.jsp"%>


<!--中间部分1-->
<script>
    // 获取地址栏参数
    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }

    $(document).ready(function () {
        console.log("页面载入");
        var page =1;
        touristList(page);
    });

    function touristList(page) {
        $.ajax({
            type: "POST",
            dataType: "json",
            data:{"method":"userOrder"},
            url:"./routesController",
            success:function (data) {
                outTourist(data);
            }
        });
        return false;
    };



    function outTourist(data) {
        var result = "";
        for(var i = 0;i<data["data"].length;i++){

            result+="<tr>";
            result+="<td>"+data["data"][i].orderId+"</td>";
            result+="<td>"+data["data"][i+1].allSpot+"</td>";
            result+="<td>"+data["data"][i+1].restaurant+"</td>";
            result+="<td>"+data["data"][i+1].live+"</td>";
            result+="<td>"+data["data"][i+1].traffice+"</td>";
            result+="<td>"+data["data"][i+1].touristTime+"</td>";
            result+="<td>"+data["data"][i+1].touristPrice+"</td>";
            result+="<td>"+data["data"][i+1].tel+"</td>";
            result+="<td>" +"<a title=\"取消行程\" onclick=\"order_del(this,"+data["data"][i].orderId+")\"  href=\"javascript:;\">"
                +"<i class=\"layui-icon\">&#xe640;</i>"+"</a>"
                "</td>";

            result+="</tr>";
            i++;
        }
        $("#mytbody").html(result);


        /*分页*/
        //字符串存储html文本
        var pagerL ="";
        //当前页
        var nowPage = data["page"];
        for(var i = 1;i<=data["pages"];i++){
            if(i===nowPage){
                pagerL+="<span class=\"current\">"+i+"</span>"
            }else {
                pagerL+="<a class=\"num\" href=\"javascript:touristList("+i+")\">"+i+"</a>";
            }
        }
        $("#pagerList").html("<a class=\"prev\" href=\"javascript:touristList(1)\" >&lt;&lt;</a>"
            +pagerL+
            "<a id=\"lastPage\" class=\"next\" href=\"javascript:touristList("+data["pages"]+")\">&gt;&gt;</a>"
        );

        $("#addRoutes").attr("onclick","");

    };


    // 用户删除
    function order_del(obj,orderId){

        //发异步删除数据
        layer.confirm('确认要取消行程吗？',function(index){
            $.ajax({
                type:"POST",
                url:"./orderController?method=orderCanser&orderId="+orderId ,
                dataType:"json",
                success:function (data) {
                    layer.alert("删除成功",{icon:6},function () {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                        // xadmin.close();
                    });
                },
                error:function (data) {
                    layer.alert("删除失败！",{icon:6},function () {
                        xadmin.close();
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();
                    });
                }
            });

        });
    };

</script>
<%--用来存储userId--%>
<input type="text" style="display: none" id="userId" name="userId">
<%--用来存储touristCompanyId--%>
<input type="text" style="display: none" id="touristCompanyId" name="touristCompanyId">
<div class="content content-nav-base datails-content" style="padding-top: 2%;min-height: 600px;">
    <div class="data-cont-wrap w1200">
    <div class="product-intro layui-clear">
        <div class="layui-card-body layui-table-body layui-table-main">
            <table class="layui-table layui-form">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>景点</th>
                    <th>餐饮</th>
                    <th>住宿</th>
                    <th>交通</th>
                    <th>时间</th>
                    <th>价格</th>
                    <th>负责人电话</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="mytbody"></tbody>
            </table>
        </div>
    </div>
</div>
</div>
<!--尾部文件-->
<%@include file="./index/footer.html"%>

</body>
</html>
